import { EPlatfrom, EPlatformType } from '../type/platfrom';

/** 获取当前应用运行的环境 */
export const getCurrentPlatfrom: EPlatformType = (() => {
    const UA = window.navigator.userAgent;
    if (/(android|iphone|ipad|ipod)/i.test(UA)) {
        if (/MicroMessenger/i.test(UA)) {
            if (/miniprogram/i.test(UA)) return EPlatfrom.MINIPROGRAME
            return EPlatfrom.WECHAT
        }
        if(/isApp/i.test(UA)){
           if(/(iphone|ipad|ipod)/i.test(UA)) return EPlatfrom.IOS;
           return EPlatfrom.ANDROID
        }
        return EPlatfrom.MOBILE_WEB
    }
    return EPlatfrom.PC_WEB;
})()